<?php 
$data['page_selected'] = 'management';
$this->load->view('constants/header', $data);?>

<div id="site_content">
	<?php $this->load->view('constants/sidebar'); ?> 
    <div id="content">
        <!-- insert the page content here -->
        <?php $this->load->view('management/menu'); ?>
        <br /><br /><br /><br />
  		<h3 align="center">Integrantes</h3>
        <table width="100%">
            <tr>
                <td style="background:none; width:110px" width="110px">
                    <a href="<?php echo base_url(); ?>user/signUp" target="_blank" title="Agregar integrante">
                        <img src="<?php echo base_url().IMG; ?>user_add.png" width="100" height="100"/>
                    </a>
                </td>
                <td style="background:none;" align="center">
                     <form method="post" action="<?php echo base_url(); ?>management/search_user">
                        Buscar&nbsp;
                        <select name="type" id="type" onChange="set_search_field()">
                            <option value="name">Nombre</option>
                            <option value="ci">C&eacute;dula</option>
                            <option value="status">Condici&oacute;n</option>
                        </select>
                        &nbsp;
                        <div id="text_field_div" style="display:inline">
                        	<input type="text" name="text" id="text">
                        </div>
                        <input type="image" alt="Submit" src="<?php echo base_url().IMG; ?>search_2.png" width="20px" height="20px" title="Buscar">
                    </form>
                </td>
            </tr>
        </table>
        <h1>Resultados de la b&uacute;squeda: "<?php echo $text; ?>" por <?php echo $type; ?></h1>
        <table width="100%" align="center">
        	<thead>
                <th align="center">
                	C&eacute;dula
                </th>
                <th align="center">
                	Nombre
                </th>
                <th align="center">
                	Tipo de Buddy
                </th>
                <th align="center">
                	Club perteneciente
                </th>
                <th align="center">
                	Condici&oacute;n
                </th>
                <th align="center" colspan="2"></th>
            </thead>
		<?php foreach($users as $u){ ?>
            <tr>
                <td align="center">
                    <?php echo $u['ci_integrante']; ?>
                </td>
                <td align="center">
                    <a href="javascript:void(0)" onclick="get_user_detail('<?php echo $u['id_integrante']; ?>')">
                        <?php echo $u['nombre'].' '.$u['apellido']; ?>
                    </a>
                </td>
                <td align="center">
                    <?php echo $u['tipo_buddy_descripcion']; ?>
                </td>
                <td align="center">
                    <?php echo $u['club_nombre']; ?>
                </td>
                <td align="center">
                    <?php echo $u['condicion']; ?>
                </td>
                <td align="center">
                    <a href="<?php echo base_url(); ?>management/edit_user/<?php echo $u['id_integrante']; ?>" title="Editar informaci&oacute;n">
                    	<img src="<?php echo base_url().IMG ?>pencil_icon.png" width="16px" height="16px"/>
                    </a>
                </td>
                <td align="center">
                	<?php 
					$img = 'Eraser-icon';
					$title = 'Inactivar';
					if($u['condicion'] != 'activo'){ 
						$img = 'checked'; 
						$title = 'Activar';
					} ?>
                    <form action="<?php echo base_url(); ?>management/update_status_user" method="post" 
                                                	onsubmit="return check('<?php echo $u['nombre'].' '.$u['apellido']; ?>', '<?php echo $title; ?>');">
                    	<input type="hidden" name="id_user" id="id_user" value="<?php echo $u['id_integrante']; ?>"/>
                        <input type="image" title="<?php echo $title ?> integrante" align="Submit" src="<?php echo base_url().IMG.$img ?>.png" width="16px" height="16px"/>
                    </form>
                </td>
            </tr>
            <tr>
                <td colspan="7">
                    <div style="display: none" id="user_detail_div<?php echo $u['id_integrante']; ?>">
                    </div>
                </td>
            </tr>
        <?php } ?>
        </table>
        
    </div>
</div>
<?php $this->load->view('constants/footer'); ?>
<script type="text/javascript">
	function check(name, action){
		if(confirm("Esta seguro de querer "+action+" al integrante: "+name)){
			return true;
		}
		else{
			return false;
		}
	}
</script>